package com.app.dialog;

import android.app.ProgressDialog;
import android.content.Context;
import android.view.Window;
import android.view.WindowManager;

import lib.common.R;


// title应为content
// 在订单详情中使用，为什么不能居中呢。
//

public class DialogProgressPercentage extends ProgressDialog {

	public static DialogProgressPercentage progressdialog = null ;
	private Context mContext;
	
	private DialogProgressPercentage(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
		mContext = context;
	}
	

	
	
	
	// 显示进度条
	public static  void ShowTitleDialog(Context context)
	{  
		
		createProgressDialog(context);
		Window window = progressdialog.getWindow();
		WindowManager.LayoutParams lp = window.getAttributes();  
		lp.dimAmount =0f;
		window.setAttributes(lp);  
		progressdialog.setContentView(R.layout.dialog_progress_percentage);
 	
	}

	
	/*
	// 显示进度条
	public static  void ShowTitleDialog(Context context, String title)
	{  

	//	String title = context.getResources().getString(content);
		
		createProgressDialog(context);
		Window window = progressdialog.getWindow();
		WindowManager.LayoutParams lp = window.getAttributes();  
		lp.dimAmount =0f;
		window.setAttributes(lp);  
		progressdialog.setContentView(R.layout.dialog_progress_percentage);
		
		
	//	TextView tv_progress_title=(TextView)window.findViewById(R.id.tv_progress_title);
	//	if(title != null)
	//		tv_progress_title.setText(title);
	
	}
	
	*/
	

	public static void dismissProgressDialog()
	{
	
		System.out.println("dissProgressDialog " + progressdialog);
///*		
		if(progressdialog==null)
		{

		}
		else
		{
			progressdialog.dismiss();
			progressdialog = null;
		}
//*/
		
		
		
	}


	
	private static  void createProgressDialog(Context context)
	{
		System.out.println("createProgressDialog " + progressdialog);
		if(progressdialog==null)
		{
			progressdialog = new DialogProgressPercentage(context);
		}


		progressdialog.setIndeterminate(true);
	//	progressdialog.setCancelable(false);
		progressdialog.setCanceledOnTouchOutside(false);
		progressdialog.show();
	}

}
